package com.lengyue.imakiba.logic;

import java.util.List;

import com.jfinal.plugin.activerecord.Db;
import com.lengyue.imakiba.data.CV;

public class CVLogic {
	/**
	 * 根据动漫Id查询对应的声优
	 * @param animeId 动漫Id
	 * @return 动漫的声优
	 */
	public static List<CV> getCVByAnime(int animeId)
	{
		return CV.dao.find("select c.* from cv c inner join anime_cv ac on c.id = ac.cv_id where ac.anime_id = ?",animeId);
	}
	/**
	 * 查询所有声优，并根据中文名排序
	 * @return
	 */
	public static List<CV> getCVAndSort()
	{
		return CV.dao.find("select * from cv order by CONVERT( name USING gbk )");
	}
	public static void deleteCV(int cvId)
	{
		Db.update("delete from anime_cv where cv_id = ?", cvId);
		Db.update("delete from cv where id = ?", cvId);
	}
}
